/**
 * Created by IntelliJ IDEA.
 * User: Bezdelnick
 * Date: 12.09.12
 * Time: 16:00
 * To change this template use File | Settings | File Templates.
 */
package fgui.control {
import fgui.GuiComponent;

import fgui.IAnimationComponent;

import flash.events.MouseEvent;
import flash.geom.Point;

import mx.controls.Label;

/**
 *
 *
 * @see com.fgui.control.TextButton
 */
public class TextButton extends GuiComponent implements IAnimationComponent {
    public var labelText:String;

    public function TextButton(coordinate:Point, size:Point, label:String = "---") {
        super(coordinate, size);
        this.labelText = label;

        var lbl:Label = new Label();
        lbl.width = size.x - 2 * margin;
        lbl.height = 20;
        lbl.x = margin;
        lbl.y = size.y / 2 - lbl.height / 2;
        lbl.text = labelText;
        addChild(lbl);

        renderColor = 0xdddddd;
        renderAlpha = 1;
        renderDefault();

        addEventListener(MouseEvent.MOUSE_OVER, renderOnMouseOver);
        addEventListener(MouseEvent.MOUSE_DOWN, renderOnMouseDown);
        addEventListener(MouseEvent.MOUSE_UP, renderOnMouseOver);
        addEventListener(MouseEvent.MOUSE_OUT, renderOnMouseOut);
    }


    public function renderOnMouseOver(event:MouseEvent):void {
        renderCustom(0xbbbbbb, 1);
    }

    public function renderOnMouseDown(event:MouseEvent):void {
        renderCustom(0x999999, 1);
    }

    public function renderOnMouseOut(event:MouseEvent):void {
        renderDefault();
    }
}
}
